home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / clisp-li.000 / clisp-li / clisp-1996-07-22 / clisp-link < prev    next >
Encoding:
Text File  |  1996-07-22  |  17.1 KB  |  479 lines

  1. #!/bin/sh
  2. # Usage: clisp-link command [more args]
  3. # where   command = link, create-module-set, add-module-set, join-modules
  4. # For more usage information, see file `doc/module.txt'.
  5. # Bruno Haible 19.10.1994
  6.  
  7. # This could as well be written in Lisp, for portability. But I don't like
  8. # the idea to have one Lisp process running while the next one is built.
  9.  
  10. usage () {
  11. echo "Usage: $0 [ link | create-module-set | add-module-set | join-modules | add-module-sets ] ..." 1>&2
  12. exit 1
  13. }
  14.  
  15. link () {
  16. # Make a link from $1 to $2. Try symbolic link, file copying.
  17. dirname=`echo "$1" | sed -e 's,/[^/]*$,,'`
  18. test -n "$dirname" || dirname='/'
  19. basename=`echo "$1" | sed -e 's,^.*/,,'`
  20. absolute_dirname=`cd "$dirname" ; /bin/pwd`
  21. if ln -s "$absolute_dirname"/"$basename" "$2"; then
  22.   :
  23. else
  24.   cp "$1" "$2"
  25. fi
  26. }
  27.  
  28. echotab () {
  29. cat <<!!
  30.     $1
  31. !!
  32. }
  33.  
  34. # Set debugging output on
  35. set -x
  36.  
  37. # Exit immediately if some command fails.
  38. set -e
  39.  
  40. # This will be filled in by `configure'.
  41. with_dynamic_modules=''
  42.  
  43. # Check number of arguments. Need at least one argument.
  44. if [ $# = 0 ] ; then
  45.   usage
  46. fi
  47.  
  48. # Where is the link kit?
  49. if [ -n "$CLISP_LINKKIT" ] ; then
  50.   linkkitdir="$CLISP_LINKKIT"
  51. else
  52.   linkkitdir=./linkkit
  53. fi
  54. if [ ! -r "$linkkitdir"/modules.d -o ! -r "$linkkitdir"/modules.c -o ! -r "$linkkitdir"/module.cc -o ! -r "$linkkitdir"/clisp.h ] ; then
  55.   echo "$0: No link kit found in $CLISP_LINKKIT" 1>&2
  56.   exit 1
  57. fi
  58. absolute_linkkitdir=`cd "$linkkitdir" ; /bin/pwd`
  59.  
  60. # Dispatch according to the first argument.
  61. case "$1" in
  62.  
  63.   link)
  64.     # This is actually obsolete because it is easier done by a simple
  65.     # "make" w.r.t. to the distmakefile.
  66.     # Usage: clisp-link link dir
  67.     if [ $# != 2 ] ; then
  68.       echo "Usage: $0 link dir" 1>&2
  69.       exit 1
  70.     fi
  71.     dir="$2"
  72.     # What to do if we abort.
  73.     trap 'rm -f "$dir"/lisp.run' 1 2 15
  74.     # Read the variables CC, CFLAGS, CLFLAGS, LIBS, X_LIBS, RANLIB, FILES
  75.     . "$dir"/makevars
  76.     if [ -z "$with_dynamic_modules" ] ; then
  77.       # Generate new modules.o, compiled from modules.c, includes modules.h
  78.       (cd "$dir" ; link "$absolute_linkkitdir"/modules.c modules.c ; ${CC} ${CFLAGS} -I"$absolute_linkkitdir" -c modules.c ; rm -f modules.c)
  79.       # Generate new lisp.run
  80.       (cd "$dir" ; ${CC} ${CFLAGS} ${CLFLAGS} modules.o ${LIBS} ${X_LIBS} -o lisp.run)
  81.     else
  82.       (cd "$dir" ; ${CC} ${CFLAGS} ${CLFLAGS} ${LIBS} ${X_LIBS} -o lisp.run)
  83.     fi
  84.     # Done.
  85.     trap '' 1 2 15
  86.     ;;
  87.  
  88.   create-module-set)
  89.     # Usage: clisp-link create-module-set moduledir {file}*
  90.     case $# in
  91.       0 | 1) echo "Usage: $0 create-module-set moduledir file ..." 1>&2
  92.              exit 1 ;;
  93.     esac
  94.     moduledir="$2"
  95.     shift
  96.     shift
  97.     files="$*"
  98.     if [ -f "$moduledir" ] ; then
  99.       if [ -d "$moduledir" ] ; then
  100.         echo "$0: $moduledir already exists" 1>&2
  101.         exit 1
  102.       else
  103.         echo "$0: $moduledir is not a directory" 1>&2
  104.         exit 1
  105.       fi
  106.     fi
  107.     mkdir "$moduledir"
  108.     modulename=`echo "$moduledir" | sed -e 's,^.*/,,'`
  109.     files_c=''
  110.     files_o=''
  111.     for file in $files; do
  112.       file=`echo "$file" | sed -e 's,\.c$,,'`.c
  113.       filename=`echo "$file" | sed -e 's,^.*/,,'`
  114.       case "$file" in
  115.         /*) relative_file="$file" ;;
  116.         *)  case "$moduledir" in
  117.               /*) relative_file="$file" ;;
  118.               *)  relative_file=`echo "$moduledir"/ | sed -e 's,[^/][^/]*/*/,../,g'`"$file" ;;
  119.             esac ;;
  120.       esac
  121.       ln -s "$relative_file" "$moduledir"/"$filename" || ln $file "$moduledir"/"$filename"
  122.       files_c="$files_c"' '"$filename"
  123.       files_o="$files_o"' '`echo "$filename" | sed -e 's,\.c$,,'`.o
  124.     done
  125.     if false; then
  126.       # No Makefile
  127.       (echo "file_list=''"
  128.        for fc in $files_c; do
  129.          fo=`echo "$fc" | sed -e 's,\.c$,,'`.o
  130.          echo 'if test -f '"$fc"'; then'
  131.          echo "  if test '"'!'"' -f $fo || test $fo -ot $fc; then"
  132.          echo '    ${CC} ${CFLAGS} -I"$absolute_linkkitdir" -c '"$fc"
  133.          echo '  fi'
  134.          echo '  file_list="$file_list"'"' $fo'"
  135.          echo 'fi'
  136.        done
  137.        echo 'NEW_FILES="$file_list"'
  138.        echo 'NEW_LIBS="$file_list"'
  139.        echo "TO_LOAD=''"
  140.       ) > "$moduledir"/link.sh
  141.     else
  142.       # With Makefile
  143.       (echo "# Makefile for CLISP module set $modulename"
  144.        echo
  145.        echo "CC ="
  146.        echo "CFLAGS ="
  147.        echo "INCLUDES="
  148.        echo
  149.        echo "CLISP ="
  150.        echo
  151.        echo "SHELL = /bin/sh"
  152.        echo
  153.        for fc in $files_c; do
  154.          fo=`echo "$fc" | sed -e 's,\.c$,,'`.o
  155.          echo "$fo : $fc"
  156.          echotab '$(CC) $(CFLAGS) -I$(INCLUDES) -c '"$fc"
  157.          echo
  158.        done
  159.       ) > "$moduledir"/Makefile
  160.       (echo "file_list=''"
  161.        echo "mod_list=''"
  162.        for fc in $files_c; do
  163.          fo=`echo "$fc" | sed -e 's,\.c$,,'`.o
  164.          mod=`echo "$fc" | sed -e 's,\.c$,,' | sed -e 's,[^A-Za-z0-9_],_,g'`
  165.          # The last sed command must agree with foreign1.lsp:to-module-name.
  166.          echo 'if test -f '"$fc"'; then'
  167.          echo '  file_list="$file_list"'"' $fo'"
  168.          echo '  mod_list="$mod_list"'"' $mod'"
  169.          echo 'fi'
  170.        done
  171.        echo 'make CC="${CC}" CFLAGS="${CFLAGS}" INCLUDES="$absolute_linkkitdir" $file_list'
  172.        echo 'NEW_FILES="$file_list"'
  173.        echo 'NEW_LIBS="$file_list"'
  174.        echo 'NEW_MODULES="$mod_list"'
  175.        echo "TO_LOAD=''"
  176.       ) > "$moduledir"/link.sh
  177.     fi
  178.     ;;
  179.  
  180.   add-module-set)
  181.     # Usage: clisp-link add-module-set moduledir source-dir destination-dir
  182.     if [ $# != 4 ] ; then
  183.       echo "Usage: $0 add-module-set moduledir source-dir destination-dir" 1>&2
  184.       exit 1
  185.     fi
  186.     moduledir="$2"
  187.     sourcedir="$3"
  188.     destinationdir="$4"
  189.     if [ ! -d "$moduledir" ] ; then
  190.       echo "$0: $moduledir is not a directory" 1>&2
  191.       exit 1
  192.     fi
  193.     if [ ! -d "$sourcedir" ] ; then
  194.       echo "$0: $sourcedir is not a directory" 1>&2
  195.       exit 1
  196.     fi
  197.     if [ -f "$destinationdir" ] ; then
  198.       if [ -d "$destinationdir" ] ; then
  199.         echo "$0: $destinationdir already exists" 1>&2
  200.         exit 1
  201.       else
  202.         echo "$0: $destinationdir is not a directory" 1>&2
  203.         exit 1
  204.       fi
  205.     fi
  206.     mkdir "$destinationdir"
  207.     absolute_currentdir=`/bin/pwd`
  208.     absolute_sourcedir=`cd "$sourcedir" ; /bin/pwd`
  209.     absolute_destinationdir=`cd "$destinationdir" ; /bin/pwd`
  210.     # What to do if we abort.
  211.     trap 'rm -rf "$absolute_destinationdir"' 1 2 15
  212.     if [ "$absolute_sourcedir" = "$absolute_destinationdir" ] ; then
  213.       echo "$0: directories $sourcedir and $destinationdir may not be the same" 1>&2
  214.       exit 1
  215.     fi
  216.     if [ ! -r "$sourcedir"/lisp.a -o ! -x "$sourcedir"/lisp.run -o ! -r "$sourcedir"/lispinit.mem -o ! -r "$sourcedir"/modules.h -o ! -r "$sourcedir"/makevars ] ; then
  217.       echo "$0: directory $sourcedir does not contain a clisp linking set" 1>&2
  218.       exit 1
  219.     fi
  220.     if [ ! -r "$moduledir/link.sh" ] ; then
  221.       echo "$0: directory $moduledir does not contain a clisp module" 1>&2
  222.       exit 1
  223.     fi
  224.     modulename=`echo "$moduledir" | sed -e 's,^.*/,,'`
  225.     # Read the variables CC, CFLAGS, CLFLAGS, LIBS, X_LIBS, RANLIB, FILES
  226.     . "$sourcedir"/makevars
  227.     # Prepare the module directory and read the variables NEW_FILES, NEW_LIBS
  228.     NEW_FILES=''
  229.     NEW_LIBS=''
  230.     NEW_MODULES=''
  231.     TO_PRELOAD=''
  232.     TO_LOAD=''
  233.     cd "$moduledir"
  234.     . ./link.sh
  235.     cd "$absolute_currentdir"
  236.     if [ -z "$with_dynamic_modules" ] ; then
  237.       # Generate new modules.h
  238.       (cat "$sourcedir"/modules.h
  239.        for mod in $NEW_MODULES ; do
  240.          echo 'MODULE('"$mod"')'
  241.        done) > "$destinationdir"/modules.h
  242.     else
  243.       # Generate every "$moduledir"/"$mod"_module.o
  244.       for mod in $NEW_MODULES ; do
  245.         if test ! -f "$moduledir"/"$mod"_module.o ; then
  246.           (cd "$moduledir"
  247.            link "$absolute_linkkitdir"/module.cc "$mod"_module.cc
  248.            ${CC} ${CFLAGS} -I"$absolute_linkkitdir" -DMODULE="$mod" -c "$mod"_module.cc
  249.            rm -f "$mod"_module.cc
  250.           )
  251.         fi
  252.         NEW_FILES="$mod"'_module.o '"$NEW_FILES"
  253.         NEW_LIBS="$mod"'_module.o '"$NEW_LIBS"
  254.       done
  255.     fi
  256.     # Generate new lisp.a
  257.     for f in ${FILES}; do
  258.       link "$sourcedir"/$f "$destinationdir"/$f
  259.     done
  260.     # Generate other libraries
  261.     for f in ${NEW_FILES}; do
  262.       link "$moduledir"/$f "$destinationdir"/$f
  263.     done
  264.     # Update the LIBS and FILES variables
  265.     LIBS=${NEW_LIBS}' '${LIBS}
  266.     FILES=${FILES}' '${NEW_FILES}
  267.     if [ -z "$with_dynamic_modules" ] ; then
  268.       # Generate new modules.o, compiled from modules.c, includes new modules.h
  269.       (cd "$destinationdir" ; link "$absolute_linkkitdir"/modules.c modules.c ; ${CC} ${CFLAGS} -I"$absolute_linkkitdir" -c modules.c ; rm -f modules.c)
  270.     fi
  271.     # Generate new lisp.run
  272.     if [ -z "$with_dynamic_modules" ] ; then
  273.       (cd "$destinationdir" ; ${CC} ${CFLAGS} ${CLFLAGS} modules.o ${LIBS} ${X_LIBS} -o lisp.run)
  274.     else
  275.       (cd "$destinationdir" ; ${CC} ${CFLAGS} ${CLFLAGS} ${LIBS} ${X_LIBS} -o lisp.run)
  276.     fi
  277.     if [ -n "$TO_PRELOAD" ] ; then
  278.       # Generate new preliminary lispinit.mem
  279.       to_preload=''
  280.       for f in $TO_PRELOAD; do
  281.         to_preload="$to_preload $moduledir/$f"
  282.       done
  283.       "$sourcedir"/lisp.run -M "$sourcedir"/lispinit.mem -q -c $to_preload
  284.       "$sourcedir"/lisp.run -M "$sourcedir"/lispinit.mem -q -i $to_preload -x "(saveinitmem \"$destinationdir/lispinit.mem\")"
  285.     fi
  286.     # Generate new lispinit.mem
  287.     to_load=''
  288.     for f in $TO_LOAD; do
  289.       to_load="$to_load $moduledir/$f"
  290.     done
  291.     if [ -n "$TO_PRELOAD" ] ; then
  292.       "$destinationdir"/lisp.run -M "$destinationdir"/lispinit.mem -q -i $to_load -x "(saveinitmem \"$destinationdir/lispinit.mem\")"
  293.     else
  294.       "$destinationdir"/lisp.run -M "$sourcedir"/lispinit.mem -q -i $to_load -x "(saveinitmem \"$destinationdir/lispinit.mem\")"
  295.     fi
  296.     # Generate new makevars
  297.     sed -e "s,^LIBS=.*\$,LIBS='${LIBS}'," -e "s,^FILES=.*\$,FILES='${FILES}'," < "$sourcedir"/makevars > "$destinationdir"/makevars
  298.     # Done.
  299.     trap '' 1 2 15
  300.     ;;
  301.  
  302.   add-module-sets)
  303.     # This is functionally the same as multiple add-module-set commands,
  304.     # but is faster and requires less disk space.
  305.     # Usage: clisp-link add-module-sets source-dir destination-dir moduledir...
  306.     if [ $# -lt 3 ] ; then
  307.       echo "Usage: $0 add-module-sets source-dir destination-dir moduledir..." 1>&2
  308.       exit 1
  309.     fi
  310.     sourcedir="$2"
  311.     destinationdir="$3"
  312.     shift
  313.     shift
  314.     shift
  315.     moduledirs="$@"
  316.     if [ ! -d "$sourcedir" ] ; then
  317.       echo "$0: $sourcedir is not a directory" 1>&2
  318.       exit 1
  319.     fi
  320.     if [ -f "$destinationdir" ] ; then
  321.       if [ -d "$destinationdir" ] ; then
  322.         echo "$0: $destinationdir already exists" 1>&2
  323.         exit 1
  324.       else
  325.         echo "$0: $destinationdir is not a directory" 1>&2
  326.         exit 1
  327.       fi
  328.     fi
  329.     for moduledir in $moduledirs; do
  330.       if [ ! -d "$moduledir" ] ; then
  331.         echo "$0: $moduledir is not a directory" 1>&2
  332.         exit 1
  333.       fi
  334.     done
  335.     mkdir "$destinationdir"
  336.     absolute_currentdir=`/bin/pwd`
  337.     absolute_sourcedir=`cd "$sourcedir" ; /bin/pwd`
  338.     absolute_destinationdir=`cd "$destinationdir" ; /bin/pwd`
  339.     # What to do if we abort.
  340.     trap 'rm -rf "$absolute_destinationdir"' 1 2 15
  341.     if [ "$absolute_sourcedir" = "$absolute_destinationdir" ] ; then
  342.       echo "$0: directories $sourcedir and $destinationdir may not be the same" 1>&2
  343.       exit 1
  344.     fi
  345.     if [ ! -r "$sourcedir"/lisp.a -o ! -x "$sourcedir"/lisp.run -o ! -r "$sourcedir"/lispinit.mem -o ! -r "$sourcedir"/modules.h -o ! -r "$sourcedir"/makevars ] ; then
  346.       echo "$0: directory $sourcedir does not contain a clisp linking set" 1>&2
  347.       exit 1
  348.     fi
  349.     for moduledir in $moduledirs; do
  350.       if [ ! -r "$moduledir/link.sh" ] ; then
  351.         echo "$0: directory $moduledir does not contain a clisp module" 1>&2
  352.         exit 1
  353.       fi
  354.     done
  355.     # Read the variables CC, CFLAGS, CLFLAGS, LIBS, X_LIBS, RANLIB, FILES
  356.     . "$sourcedir"/makevars
  357.     if [ -z "$moduledirs" ] ; then
  358.       # Just make links from $destinationdir to $sourcedir
  359.       for f in lisp.run lispinit.mem modules.h makevars ${FILES}; do
  360.         link "$sourcedir"/$f "$destinationdir"/$f
  361.       done
  362.       if [ -z "$with_dynamic_modules" ] ; then
  363.         if [ -r "$sourcedir"/modules.o ] ; then
  364.           link "$sourcedir"/modules.o "$destinationdir"/modules.o
  365.         fi
  366.       fi
  367.     else
  368.       # Prepare the module directories and read their variables
  369.       allmodulevars=''
  370.       for moduledir in $moduledirs; do
  371.         modulename=`echo "$moduledir" | sed -e 's,^.*/,,'`
  372.         # Prepare the module directory and read the variables NEW_FILES, NEW_LIBS
  373.         NEW_FILES=''
  374.         NEW_LIBS=''
  375.         NEW_MODULES=''
  376.         TO_PRELOAD=''
  377.         TO_LOAD=''
  378.         cd "$moduledir"
  379.         . ./link.sh
  380.         cd "$absolute_currentdir"
  381.         # This is a crazy way to build doubly nested lists.
  382.         allmodulevars="$allmodulevars""@@SEP1@@""moduledir=\""`echo "$moduledir" | sed -e 's,",\\\\",g' -e 's, ,@@SEP3@@,g'`"\""
  383.         allmodulevars="$allmodulevars""@@SEP2@@""modulename=\""`echo "$modulename" | sed -e 's,",\\\\",g' -e 's, ,@@SEP3@@,g'`"\""
  384.         allmodulevars="$allmodulevars""@@SEP2@@""NEW_FILES=\""`echo "$NEW_FILES" | sed -e 's,",\\\\",g' -e 's, ,@@SEP3@@,g'`"\""
  385.         allmodulevars="$allmodulevars""@@SEP2@@""NEW_LIBS=\""`echo "$NEW_LIBS" | sed -e 's,",\\\\",g' -e 's, ,@@SEP3@@,g'`"\""
  386.         allmodulevars="$allmodulevars""@@SEP2@@""NEW_MODULES=\""`echo "$NEW_MODULES" | sed -e 's,",\\\\",g' -e 's, ,@@SEP3@@,g'`"\""
  387.         allmodulevars="$allmodulevars""@@SEP2@@""TO_PRELOAD=\""`echo "$TO_PRELOAD" | sed -e 's,",\\\\",g' -e 's, ,@@SEP3@@,g'`"\""
  388.         allmodulevars="$allmodulevars""@@SEP2@@""TO_LOAD=\""`echo "$TO_LOAD" | sed -e 's,",\\\\",g' -e 's, ,@@SEP3@@,g'`"\""
  389.       done
  390.       if [ -z "$with_dynamic_modules" ] ; then
  391.         # Generate new modules.h
  392.         (cat "$sourcedir"/modules.h
  393.          for modulevars in `echo $allmodulevars | sed -e 's,@@SEP1@@, ,g'`; do
  394.            for assignment in `echo $modulevars | sed -e 's,@@SEP2@@, ,g'`; do
  395.              eval `echo $assignment | sed -e 's,@@SEP3@@, ,g'`
  396.            done
  397.            for mod in $NEW_MODULES ; do
  398.              echo 'MODULE('"$mod"')'
  399.            done
  400.          done) > "$destinationdir"/modules.h
  401.       else
  402.         # Generate every "$moduledir"/"$mod"_module.o
  403.         for modulevars in `echo $allmodulevars | sed -e 's,@@SEP1@@, ,g'`; do
  404.           for assignment in `echo $modulevars | sed -e 's,@@SEP2@@, ,g'`; do
  405.             eval `echo $assignment | sed -e 's,@@SEP3@@, ,g'`
  406.           done
  407.           for mod in $NEW_MODULES ; do
  408.             if test ! -f "$moduledir"/"$mod"_module.o ; then
  409.               (cd "$moduledir"
  410.                link "$absolute_linkkitdir"/module.cc "$mod"_module.cc
  411.                ${CC} ${CFLAGS} -I"$absolute_linkkitdir" -DMODULE="$mod" -c "$mod"_module.cc
  412.                rm -f "$mod"_module.cc
  413.              )
  414.             fi
  415.           done
  416.         done
  417.       fi
  418.       # Generate new lisp.a
  419.       for f in ${FILES}; do
  420.         link "$sourcedir"/$f "$destinationdir"/$f
  421.       done
  422.       PRELOAD=''
  423.       LOAD=''
  424.       for modulevars in `echo $allmodulevars | sed -e 's,@@SEP1@@, ,g'`; do
  425.         for assignment in `echo $modulevars | sed -e 's,@@SEP2@@, ,g'`; do
  426.           eval `echo $assignment | sed -e 's,@@SEP3@@, ,g'`
  427.         done
  428.         # Generate other libraries
  429.         if [ -n "$with_dynamic_modules" ] ; then
  430.           for mod in $NEW_MODULES ; do
  431.             NEW_FILES="$mod"'_module.o '"$NEW_FILES"
  432.             NEW_LIBS="$mod"'_module.o '"$NEW_LIBS"
  433.           done
  434.         fi
  435.         for f in ${NEW_FILES}; do
  436.           link "$moduledir"/$f "$destinationdir"/$f
  437.         done
  438.         # Update the LIBS and FILES variables
  439.         LIBS=${NEW_LIBS}' '${LIBS}
  440.         FILES=${FILES}' '${NEW_FILES}
  441.         for f in $TO_PRELOAD; do
  442.           PRELOAD=${PRELOAD}' '"$moduledir/$f"
  443.         done
  444.         for f in $TO_LOAD; do
  445.           LOAD=${LOAD}' '"$moduledir/$f"
  446.         done
  447.       done
  448.       if [ -z "$with_dynamic_modules" ] ; then
  449.         # Generate new modules.o, compiled from modules.c, includes new modules.h
  450.         (cd "$destinationdir" ; link "$absolute_linkkitdir"/modules.c modules.c ; ${CC} ${CFLAGS} -I"$absolute_linkkitdir" -c modules.c ; rm -f modules.c)
  451.       fi
  452.       # Generate new lisp.run
  453.       if [ -z "$with_dynamic_modules" ] ; then
  454.         (cd "$destinationdir" ; ${CC} ${CFLAGS} ${CLFLAGS} modules.o ${LIBS} ${X_LIBS} -o lisp.run)
  455.       else
  456.         (cd "$destinationdir" ; ${CC} ${CFLAGS} ${CLFLAGS} ${LIBS} ${X_LIBS} -o lisp.run)
  457.       fi
  458.       if [ -n "$PRELOAD" ] ; then
  459.         # Generate new preliminary lispinit.mem
  460.         "$sourcedir"/lisp.run -M "$sourcedir"/lispinit.mem -q -c ${PRELOAD}
  461.         "$sourcedir"/lisp.run -M "$sourcedir"/lispinit.mem -q -i ${PRELOAD} -x "(saveinitmem \"$destinationdir/lispinit.mem\")"
  462.       fi
  463.       # Generate new lispinit.mem
  464.       if [ -n "$PRELOAD" ] ; then
  465.         "$destinationdir"/lisp.run -M "$destinationdir"/lispinit.mem -q -i ${LOAD} -x "(saveinitmem \"$destinationdir/lispinit.mem\")"
  466.       else
  467.         "$destinationdir"/lisp.run -M "$sourcedir"/lispinit.mem -q -i ${LOAD} -x "(saveinitmem \"$destinationdir/lispinit.mem\")"
  468.       fi
  469.       # Generate new makevars
  470.       sed -e "s,^LIBS=.*\$,LIBS='${LIBS}'," -e "s,^FILES=.*\$,FILES='${FILES}'," < "$sourcedir"/makevars > "$destinationdir"/makevars
  471.     fi
  472.     # Done.
  473.     trap '' 1 2 15
  474.     ;;
  475.  
  476.   *) usage;;
  477. esac
  478.  
  479.